<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="Keywords" content="">
	   <meta name="description" content="">
    <title>评价</title>

    <!--公共部分-->
    <link href="/static/comment/css/layout.css" type="text/css" rel="stylesheet" />
	<script src="/static/comment/js/jquery-1.11.1.min.js" type="text/javascript"></script>
    <!--私有部分-->
    <link href="/static/comment/css/default.style.css" type="text/css" rel="stylesheet" />
	<script src="/static/comment/js/default.common.js" type="text/javascript"></script>
	<script src="/static/comment/js/plugin.js" type="text/javascript"></script>
  <script src="/static/public/layer/layer.js" type="text/javascript"></script>
</head>
<body>

<div class="wrap">
	<!--star header-->

	<!--end  header-->
	<!--star main-->
    <div class="wrap_main fix">


        <!--content star-->
        <div class="col_main">

        	<!--star sub_left-->
            <div class="sub_left" id="jigouxiangqing">
              <!--star md-->
              <div class="u_pingjia_main fs16">
                  <h2>课程评价</h2>
                  <div class="pj_item">
                  	<div class="fop-label">评分：</div>
                      <div class="fop-main">
                      	<div id="rate-comm"></div>
                      </div>
                  </div>

                  <div class="pj_item pos_item">
                  	<div class="fop-label">评价：</div>
                      <div class="fop-main" style="width:450px;height:170px;">
                          <div class="txtAnum" style="height:100px;"><textarea onkeyup="keyAnum($(this))" name="content" placeholder="留下你的牛评吧~"></textarea></div>
                          <div class="r tar">
                              <strong id="ceiling">字数已到上限啦~</strong>
                              <span class="c-666666 p-t10">最少10个字，最多可输入500字，你已输入<font id="word">0</font>字</span>
                          </div>
                      </div>
                  </div>
                  <div class="pj_item">
                  	<div class="fop-label">&nbsp;</div>
                      <div class="fop-main">
                      	<input class="btnSubmit btn-ff6c00-ground" type="submit" value="发表评论" onclick="return chkLogin();"/>
                      </div>
                  </div>

              </div>
              <!--end md-->

            </div>
        	<!--end sub_left-->




        </div>
        <!--content end-->

		<div style="height:100px; clear:both;"></div>
    </div>
	<!--end  main-->

</div>
<script src="/static/comment/js/comment.js"></script><!--点评效果-->
<script>
function jsReplay(obj){
	$(obj).parent('.replayID').siblings('.reply_box').show();
	$(obj).parent('.replayID').siblings('.reply_box').find('input').focus();
	$(obj).parent('.replayID').hide();
}
function jsCancel(obj){
	$(obj).parent().parent('.reply_box').siblings('.replayID').show();
	$(obj).parent().siblings().find('input').val('');
	$(obj).parent().parent('.reply_box').hide();
}
//textarea输入框限制字数
function keyAnum(obj){
	var len = $(obj).val().length;
	if (len > 500) {
		$("#ceiling").show();
		var num = $(obj).val().substring(0, 500);
		$(obj).val(num);
		return false;
	}
	else {
		$("#ceiling").hide();
		$("#word").text($(obj).val().length);
		return false;
	}
}
function chkLogin(){
  var socre = parseInt($(".rater-star-result").html());
	var tea = $('textarea[name="content"]');
  if(isNaN(socre)){
    alert('请评分');
    return false;
  }
	if(tea.val()==''){
		alert('你还没有评论，请输入你的评论内容');
		tea.focus();//绑定焦点
		return false;
	}else{
		if(tea.val().length >= 10){

        // $.post('/user/orders/comment_ajax',{socre:socre,comment:tea},function(res){
        //   alert(res);
        // });
      jQuery.ajax({
          url:'/user/orders/comment_ajax',
          data: "socre="+socre+"&comment="+tea.val()+"&order_id=<{$order_id}>",
          type:'post',
          dataType:'json',
          success:function(res){
              if(res.error == 1){
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index);
                parent.layer.msg(res.msg, {icon:5, anim: 6});
              }else if(res.error == 2){
                parent.layer.msg(res.msg, {icon:5, anim: 6});
              }else{
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index);
                parent.layer.msg(res.msg, {icon:6, anim: 6});
              }

          }
      });

      // $.ajax({
      //   url:'/user/orders/comment/1',
      //   type:'post',
      //   dataType:'json',
      //   data:{'socre':socre,'comment':tea},
      //   success:function(res){
      //     alert(res);
      //   }
      // })
			// alert('评论成功!');
			tea.val('');//清空
		}else{
			alert('最少10个字!');
		}
	}
}
</script>
</body>
</html>
